{template 'common/header'}
{if $do == 'operator'}
<div class="form-horizontal form">
	<h4>设置可操作用户</h4>
	<div class="search" style="padding:0px;padding-bottom:15px;">
		<form action="site.php" method="get">
		<input type="hidden" name="act" value="solution" />
		<input type="hidden" name="do" value="operator" />
		<input type="hidden" name="name" value="{$_GPC['module']}" />
		<table class="table table-bordered tb">
			<tr>
				<th>用户名</th>
				<td><input class="span6" name="username" id="" type="text" value="{$_GPC['username']}"></td>
			</tr>
			 <tr class="search-submit">
				<td colspan="2"><button class="btn btn-default pull-right"><i class="fa fa-search fa-lg"></i> 搜索</button></td>
			 </tr>
		</table>
		</form>
	</div>
	<table class="table table-hover">
		<thead class="navbar-inner">
			<tr>
				<th class="col-xm-2">用户名</th>
				<th style="text-align:right;">操作</th>
			</tr>
		</thead>
		<tbody>
			{loop $members $m}
			<tr>
				<td>{$m['username']}</td>
				<td style="text-align:right;">
					<a href="{php echo url('member/edit', array('id' => $m['uid']));}">编辑用户</a>&nbsp;|&nbsp;<a href="{php echo url('site/solution/menu', array('module' => $_GPC['module'], 'memberid' => $m['uid']));}">设置权限</a>
				</td>
			</tr>
			{/loop}
		</tbody>
	</table>
	{$pager}
</div>
{elseif $do=='menu'}
<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
<div class="main">
	<input type="hidden" name="act" value="{$action}" />
	<input type="hidden" name="op" value="post" />
	<input type="hidden" name="do" value="menu" />
	<input type="hidden" name="name" value="{$_GPC['module']}" />
	<input type="hidden" name="uid" value="{$member['uid']}" />
	<h4>用户管理</h4>
	<table class="tb">
		<tr>
			<th><label for="">管理员名称</label></th>
			<td>
				<input type="text" class="span4" id="name" value="{$member['username']}" readonly="readonly"/>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<div class="sub-item" id="table-list">
					<h4 class="sub-title">权限设置</h4>
					<div class="sub-content">
						<table class="table table-hover">
							<thead class="navbar-inner">
								<tr>
									<th style="width:40px;" class="row-first">选择</th>
									<th>导航标题</th>
									<th>链接地址</th>
								</tr>
							</thead>
							<tbody>
								{loop $allmenus $menu}
								<tr>
									<td class="row-first">
										<input type="hidden" name="eid[]" value="{$menu['eid']}" />
										<input type="hidden" name="state[]" value="{$menu['state']}" />
										<input type="hidden" name="doname[]" value="{$menu['do']}" />
										<input type="hidden" name="title[]" value="{$menu['title']}" />
										<input type="hidden" name="check[]" {if !empty($menu['eid']) && !empty($menus[$menu['eid']]['enable'])} value="true"{elseif $menus[$menu['state']]['enable']} value="true"{/if} />
										<input class="modules check" type="checkbox" {if !empty($menu['eid']) && !empty($menus[$menu['eid']]['enable'])} checked{elseif $menus[$menu['state']]['enable']} checked{/if} />
									</td>
									<td>{$menu['title']}</td>
									<td><a href="{$menu['url']}" target="_blank">{php echo str_replace('&','&amp;', $menu['url']);}</a></td>
								</tr>
								{/loop}
							</tbody>
						</table>
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<th></th>
			<td>
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary" name="submit" value="提交" />
			</td>
		</tr>
	</table>
</div>
</form>
<script type="text/javascript">
<!--
	$('.check').click(function(){
		$(this).parent().find("input[name='check[]']").val($(this).attr('checked') == 'checked');
	});
//-->
</script>
{elseif $do == 'management'}
<div id="global-bg">
	<div id="global" class="img-rounded">
		<div id="header">
			<div class="logo pull-left" {if !empty($_W['setting']['copyright']['blogo'])}style="background:url('{$_W['setting']['copyright']['blogo']}') no-repeat;"{/if}>{if !empty($_W['setting']['copyright']['sitename'])}{$_W['setting']['copyright']['sitename']}{/if}</div>
			<!-- 导航 -->
			<div class="hnav clearfix">
				<div class="row-fluid">
					<ul class="hnav-main text-center unstyled pull-left" style="width:55%;">
						{if $_W['isfounder']}
						<li class="hnav-parent"><a href="{php echo url('account/permission', array('id' => $_W['weid'], 'module' => $modulename, 'reference' => 'solution'))}" target="main">设置操作用户</a></li>
						<li class="hnav-parent"><a href="https://mp.weixin.qq.com/" target="main">参数设置</a></li>
						{/if}
						<li class="hnav-parent"><a href="https://mp.weixin.qq.com/" target="main">公众平台</a></li>
					</ul>
					<!-- 右侧管理菜单 -->
					<ul class="hnav-manage text-center unstyled pull-right">
						<li class="hnav-parent" id="wechatpanel">
							<a href="javascript:;"><i class="fa fa-chevron-down fa-lg"></i><span id="current-account">{if $_W['account']}{$_W['account']['name']}{else}请切换公众号{/if}</span></a>
							<ul class="hnav-child unstyled text-left">
								{php $i = 1;}
								{loop $wechats $account}
									<li><a href="{php echo url('account/switch', array('id' => $account['weid']))}" onclick="return ajaxopen(this.href, function(s) {switchHandler(s)})">{$account['name']}</a></li>
									{if $i >= 10}
										<li style="background:#4f525b;"><a href="{php echo url('account/display')}" target="main">点击查看更多</a></li>
										{php break;}
									{/if}
									{php $i++;}
								{/loop}
							</ul>
						</li>
						<li class="hnav-parent"><a href=""><i class="fa fa-user fa-lg"></i>{$_W['username']}</a></li>
						<li class="hnav-parent"><a href="{php echo url('member/logout')}"><i class="icon-signout icon-large"></i>退出</a></li>
					</ul>
					<!-- end -->
				</div>
			</div>
			<!-- end -->
		</div>
		<!-- 头部 end -->
		<div class="content-main">
			<table width="100%" height="100%" cellspacing="0" cellpadding="0" id="frametable">
				<tbody>
					<tr>
						<td valign="top" height="100%" class="content-left" style="padding-top:0px;">
							<div class="sidebar-nav" style="">
								<ul class="snav unstyled">
									{loop $menus $item}
									<li class="snav-list"><a href="{$item[1]}" target="{if $item[2]}_blank{else}main{/if}">{$item[0]}<i class="arrow fa fa-caret-right"></i></a>{if !empty($item['childItems'])}<a href="{$item['childItems'][1]}" target="main" class="snav-small">{$item['childItems'][0]}</a>{/if}</li>
									{/loop}
								</ul>
							</div>
						</td>
						<td valign="top" height="100%" class="content-right" style=""><iframe width="100%" scrolling="yes" height="100%" frameborder="0" style="min-width:800px; overflow:visible; height:100%; background:#FFF;" name="main" id="main" src="{$iframe}"></iframe></td>
					</tr>
				</tbody>
			</table>
		</div>
		</div>
	</div>
</div>
<script type="text/javascript">
function max(a) {
	var b = a[0];
	for(var i=1;i<a.length;i++){ if(b<a[i])b=a[i]; }
	return b;
}

function switchHandler(s) {
	var mainurl = window.frames['main'].location;
	if (window.frames['main'].location.href.indexOf('global') > -1) {
		window.top.location.href = '?do=profile';
	}
	window.top.location.href = '?do=profile';
	$('#current-account').html(s);
}
function strlen(str) {
		var n = 0;
		for(i=0;i<str.length;i++){
			var leg=str.charCodeAt(i);
			n+=1;
		}
		return n;
}
function leftScrollbar(e) {
	$('.content-left').mCustomScrollbar({
		theme:"dark-thin",
		autoHideScrollbar:true,
		scrollButtons:{
			enable:true
		},
		advanced:{
			updateOnBrowserResize:true,
			updateOnContentResize:true,
			autoScrollOnFocus:false
		},
		scrollInertia:150
	});
}

$(document).ready(function() {
	$(".hnav").delegate(".hnav-parent", "mouseout", function(){
		$(".hnav-child").hide();
	});
	//左侧导航
	//初始化第一条显示
	$(".sidebar-nav .snav").eq(0).find(".snav-header").addClass("open");
	$(".sidebar-nav .snav").eq(0).find(".snav-list").addClass("open");
	$(".sidebar-nav").delegate(".snav-header", "click", function(){
		var a = $(this).hasClass("open");
		$(".sidebar-nav .snav .snav-header").removeClass("open");
		$(".sidebar-nav .snav .snav-list").addClass("hide");
		if(a) {
			$(this).removeClass("open");
			$(this).parent().find(".snav-list").each(function(i) {
				$(this).addClass("hide");
			});
		} else {
			$(this).addClass("open");
			$(this).parent().find(".snav-list").each(function(i) {
				$(this).removeClass("hide");
			});
		}
		//右侧菜单滚动控制
		var b = "#" + $(this).parent().attr("id");
		$('.content-left').mCustomScrollbar("update");
		$('.content-left').mCustomScrollbar("scrollTo", b);
		return false;
	});
	$(".sidebar-nav .snav").each(function() {
		if($(this).find(".snav-header").hasClass("open")) {
			$(this).find(".snav-list").each(function() {
				$(this).toggleClass("hide");
			});
		}
		$(this).find(".snav-list").each(function() {
			if($(this).hasClass("current")) {
				$(this).parent().find(".snav-header").toggleClass("open");
				$(this).parent().find(".snav-list").each(function() {
					$(this).toggleClass("hide");
				});
			}
		});
		$(this).find(".snav-list a,.snav-header-list a").click(function() {
			$(".snav-list,.snav-header-list").removeClass("current");
			$(this).parent().addClass("current");
			if ($(this).attr('target') == '_blank') {
				return true;
			} else {
				window.frames['main'].location.href= $(this).attr("href");
			}
			return false;
		});
	});
});


$(function() {
	//调整框架宽高 兼容ie8
	$(".content-main, .content-main .content-right").height($(window).height()-40-20);
	$(".content-main .content-left").height($(window).height()-40-20-40);
	$("#main").width($(window).width()-200-20);
	//右侧菜单滚动控制
	leftScrollbar();
});
$(window).resize(function(){
	//调整框架宽高 兼容ie8
	$(".content-main, .content-main .content-right").height($(window).height()-40-20);
	$(".content-main .content-left").height($(window).height()-40-20-40);
	$("#main").width($(window).width()-200-20);
});
</script>

{/if}
